<template>
  <div class="bar-progress">
    <span class="text">{{currentTime |formatTime}}</span>
    <van-slider :value="progress" @input="onInput" @drag-start="dragStart" @drag-end="dragEnd" button-size="15" />
    <span class="text">{{duration|formatTime}}</span>
  </div>
</template>

<script  type='module'>
export default {
  props: {
    currentTime: Number,
    duration: Number,
    // 获取进度
    progress: Number
  },
  data () {
    return {
      // playProgress:0
    }
  },
  methods: {
    onInput (musicPlayValue) {
      // Toast('当前值：' + value);
      this.$emit('input', musicPlayValue)
      // console.log('当前值：' + value)
    },
    dragStart (value) {
      this.$emit('dragStart', value)
    },
    dragEnd (value) {
      this.$emit('dragEnd', value)
    }
  },
  // 格式化时间
  filters: {
    formatTime (value) {
      const mins = Math.floor(value / 60)
      let secend = Math.floor(value % 60)
      secend = secend > 9 ? secend : ('0' + secend)
      return mins + ':' + secend
    }
  }
}
</script>

<style scoped lang="less">
.bar-progress {
  width: 90%;
  margin: 30px auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.text {
  color: #333;
  font-size: 15px;
  margin: 0 18px;
}
</style>
